
#include "ka-app/window.h"

using namespace ka;

IWindowDriver::~IWindowDriver() {
    /*nothing*/
}

Window::Window() 
: _driver(NULL),
_handle(NULL) {
    _driver = getDefaultWindowDriver();
    if (_driver) {
        _handle = _driver->createWindowHandle();
    }
}

Window::Window(IWindowDriver *driver) 
: _driver(driver),
_handle(NULL) {
    if (_driver) {
        _handle = _driver->createWindowHandle();
    }
}

Window::~Window() {
    if (_driver) {
        _driver->destroyWindowHandle(_handle);
    }
}

void *Window::getWindowHandle() {
    return _handle;
}

void Window::setTitle(const char *title) {
    if (_driver) {
        _driver->setWindowTitle(_handle, title);
    }
}

void Window::show() {
    if (_driver) {
        _driver->showWindow(_handle);
    }
}